package nowCoder;

import SCHLUMBERGER.Integer_Devide;

import java.util.ArrayList;

/**
 * Created by Ghost on 2015/4/8.
 */
public class PrintListFromTailToHead {
    private void print(ListNode root, ArrayList<Integer> rst){
        if(root==null)
            return ;
        print(root.next,rst);
        rst.add(root.val);
    }
    public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
        ArrayList<Integer> rst = new ArrayList<Integer>();
        print(listNode, rst);
        return rst;
    }
    public static void main(String[] args){
        PrintListFromTailToHead pro = new PrintListFromTailToHead();
        ListNode root = new ListNode(1);
        root.next = new ListNode(2);
        root.next.next = new ListNode(3);
        root.next.next.next = new ListNode(4);
        root.next.next.next.next = new ListNode(5);
        System.out.println(pro.printListFromTailToHead(null));
    }
}
